package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.basedoc.model.PersonalInfo;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.ordermanager.model.ServicePoint;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;


/**
 * 司机档案
 * @author ZhaoYuJing
 *
 */
@Entity
@Table(name = "bd_driver")
@Indexed
public class Driver extends BaseModel {

	private static final long serialVersionUID = -5584685130435654311L;
	
	@Id
	@In
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkDriver;
	
	/** 所属服务点*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkServicePoint")
    @IndexedEmbedded(depth = 1)
	private ServicePoint servicePoint;
	
	/** 基本信息*/
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="pkPersonalInfo")
	@IndexedEmbedded(depth = 1)
	private PersonalInfo personalInfo;
	
	
	/** 司机状态  */
	@Enumerated(EnumType.STRING)
	@Field
	@FieldBridge(impl = EnumBridge.class)
	private DriverStatus driverStatus;

	@Version
	private Integer version;

	/** 状态 */
	@Field
	@Column
	private Boolean seal;
	
	
	@JsonSerialize(using = EnumSerializer.class)
	public enum DriverStatus {
		Passage("在途"), Free("空闲");

		private String display;

		DriverStatus(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}
	
	public Long getPkDriver() {
		return pkDriver;
	}

	public void setPkDriver(Long pkDriver) {
		this.pkDriver = pkDriver;
	}

	public DriverStatus getDriverStatus() {
		return driverStatus;
	}

	public void setDriverStatus(DriverStatus driverStatus) {
		this.driverStatus = driverStatus;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getSeal() {
		return seal;
	}

	public void setSeal(Boolean seal) {
		this.seal = seal;
	}

	public ServicePoint getServicePoint() {
		return servicePoint;
	}

	public void setServicePoint(ServicePoint servicePoint) {
		this.servicePoint = servicePoint;
	}

	public PersonalInfo getPersonalInfo() {
		return personalInfo;
	}

	public void setPersonalInfo(PersonalInfo personalInfo) {
		this.personalInfo = personalInfo;
	}
	
}
